/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modes;

import main.ColorSensorChew;
import main.Engine;
import main.SensorEngine;
import main.SonicSensor;
import navigation.Navigator;

/**
 * abstract class for a mode
 * @author Max
 */
public abstract class AMode
{

    static protected Engine engine;
    static protected SensorEngine rotationSensor;
    static protected ColorSensorChew color;
    static protected Navigator navi;
    static protected SonicSensor sonic;

    /**
     * Constructor for modes
     *
     * @param en Engine
     * @param r SensorEngine
     * @param c ColorSensor
     * @param s SonicSensor
     * @param nav Navigator
     */
    public AMode(Engine en, SensorEngine r, ColorSensorChew c, SonicSensor s, Navigator nav)
    {
        navi = nav;
        sonic = s;
        engine = en;
        rotationSensor = r;
        color = c;
    }

    /**
     * sets the navigator for all modes
     * @param nav Navigator
     */
    static public void setNavi(Navigator nav)
    {
        navi = nav;
    }

    /**
     * Checks wether the crossroad in front of Chewie is not free
     * @return true if crossroad is not free
     */
    protected boolean isCrossNotFree()
    {
        sonic.calcDistance();
        return sonic.getCurrentValue() <= 18;
    }

    /**
     * Checks wether there is an object near the crossroad
     * @return true if there is an object near the crossroad
     */
    protected boolean isAfterCrossNotFree()
    {
        sonic.calcDistance();
        return sonic.getCurrentValue() <= 10;
    }
}
